import os
import sys
import json
from config import settings
import getpass


def auth(username=None, password=None, paypass=None, type=None):
    with open(os.path.join(settings.DB_DIR, 'user_info.json'), 'r') as f:
        user_info = json.load(f)
    user = user_info.get(username, None)
    if user:
        if type == 'shop':
            if user['password'] == password:
                return True
        elif type == 'pay':
            if user['paypass'] == paypass:
                return True
        else:
            return False
    else:
        return False
